
package com.insigma.business.qrcode.common.converter;



import com.insigma.business.qrcode.soldier.dto.PlacementInfoDO;
import com.insigma.business.qrcode.soldier.dto.PlacementInfoDTO;
import com.insigma.business.qrcode.soldier.request.PlacementInfoBSearcher;
import com.insigma.business.qrcode.soldier.request.PlacementInfoInsertRequest;
import com.insigma.business.qrcode.soldier.request.PlacementInfoSearchRequest;
import com.insigma.business.qrcode.soldier.request.PlacementInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class PlacementInfoProviderConverter extends AbstractConverter<PlacementInfoDTO, PlacementInfoDO> {

    private final static PlacementInfoProviderConverter placementInfoConverter = new PlacementInfoProviderConverter();

    private PlacementInfoProviderConverter(){}

    
    public static PlacementInfoBSearcher convertRequestSO2Searcher(final PlacementInfoSearchRequest request){
        final PlacementInfoBSearcher placementInfoBSearcher = new PlacementInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,placementInfoBSearcher);
        return placementInfoBSearcher;
    }

    
    public static PlacementInfoDO convertRequestUO2DO(final PlacementInfoUpdateRequest placementInfoUpdateRequest) {
        final PlacementInfoDO placementInfoDO = new PlacementInfoDO();
        BeanUtils.copyProperties(placementInfoUpdateRequest,placementInfoDO);
        
        return placementInfoDO;
    }

    
    public static PlacementInfoDO convertRequestIO2DO(final PlacementInfoInsertRequest placementInfoInsertRequest) {
        final PlacementInfoDO placementInfoDO = new PlacementInfoDO();
        BeanUtils.copyProperties(placementInfoInsertRequest,placementInfoDO);
        return placementInfoDO;
    }

    
    public static List<PlacementInfoDTO> convertResponseDOList2DTOList(final List<PlacementInfoDO> placementInfoDOList){
        return placementInfoConverter.convertGenericResponseDOList2DTOList(placementInfoDOList);
    }

    
    public static PlacementInfoDTO convertResponseDO2DTO(final PlacementInfoDO placementInfoDO){
        return placementInfoConverter.convertGenericResponseDO2DTO(placementInfoDO);
    }

    
    @Override
    protected PlacementInfoDTO doConvertResponseDO2DTO(PlacementInfoDO placementInfoDO) {
        final PlacementInfoDTO placementInfoDTO = new PlacementInfoDTO();
        try {
            BeanUtils.copyProperties(placementInfoDO, placementInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return placementInfoDTO;
    }

}
